// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-11

package responses

import (
	"gitee.com/go-libs/db-xorm/db"
	"server/app/http/models"
	"server/app/kind"
)

// CouponResponse
// 优惠券.
type CouponResponse struct {
	Id               kind.CouponId
	UserId           kind.UserId
	ArcadeId         kind.ArcadeId
	State            kind.CouponState
	Type             kind.OrderKind
	TypeText         string
	Available        bool
	AvailableBegin   db.Date
	AvailableEnd     db.Date
	DiscountType     kind.DiscountType
	DiscountTypeText string
	DiscountValue    kind.Balance
	DiscountMax      kind.Balance
	Name             string
}

// With
// 数据绑定.
func (o *CouponResponse) With(m *models.Coupon) *CouponResponse {
	o.Id = m.Id
	o.UserId = m.UserId
	o.ArcadeId = m.ArcadeId
	o.State = m.State
	o.Type = m.Type
	o.TypeText = m.Type.Text()
	o.AvailableBegin = m.AvailableBegin
	o.AvailableEnd = m.AvailableEnd
	o.DiscountType = m.DiscountType
	o.DiscountTypeText = m.DiscountType.Text()
	o.DiscountValue = m.DiscountValue
	o.DiscountMax = m.DiscountMax
	o.Name = m.Name

	o.Available = m.Available()
	return o
}
